<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://www.zkingsoft.com" prefix="matrix"%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/plugin/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
	<!-- 搜索框部分start -->
<matrix:btn value="user:search">
	<div class="row" >
		<div class="col-sm-12" >
			<form class="form-inline" id="serchform">
				
					<div class="btn-group search-list " data-for="search-text">
						     <div class="form-group mr-20">
								<label>消费码：</label>
								<input id="search-text" name="orderCode" placeholder="输入消费码"
									type="text" class="form-control">
							</div> 
					     <!--   <div class="form-group mr-20">
								<label>活动名称：</label>
								<input id="search-text" name="hacName" placeholder="输入活动名称"
									type="text" class="form-control">
							</div>  -->
							  <div class="form-group mr-20">
								<label>微信昵称：</label>
								<input id="search-text" name="nickName" placeholder="输入微信昵称"
									type="text" class="form-control">
							</div> 
							 <div class="form-group mr-20">
								<label>联系电话：</label>
								<input id="search-text" name="userPhone" placeholder="输入联系电话"
									type="text" class="form-control">
							</div> 
							 <input type="hidden" name="sort" value="create_time"> 
						    <input type="hidden" name="order" value="DESC">  
							<div class="form-group mr-20">
								<label>订单类型：</label>
								<select  name="orderType" class="form-control" id="orderType">
									  <option value="" >请选择</option>
									 <option value="1" >分享</option>
						    		 <option value="2" >助力</option>
								</select>
								
							</div>
							<div class="form-group mr-20">
								<label>订单状态：</label>
								<select  name="orderStatus" class="form-control" id="orderStatus">
								    <option value="" >请选择</option>
									 <option value="1" >待消费</option>
						    		 <option value="2" >已消费</option>
						    		 <option value="3" >已失效</option>
								</select>
							
							</div>
					</div>
					
					<div class="form-group mr-20">
						<button  onclick="myGrid.serchData()" type="button" class="btn btn-info"><i class="fa fa-search " ></i> 搜索</button>
						<button  type="reset" class="btn btn-info "><i class="fa fa-refresh " ></i> 重置</button>
					</div>
				
			</form>
		</div>
	</div>
</matrix:btn>
	<!-- 搜索框部分en -->
<div class="ibox-content radius-5 mt-5 mpanel">
		
	<div class="row" >
		<div class="col-sm-12" >
			<!-- 功能按钮部分 -->
					<div class="option-bar">
						
					</div>
			<table id="mgrid" >
				<thead>
					<tr>
						<!-- <th data-checkbox="true"  ></th> -->
						<th data-formatter="MGrid.indexfn" data-align="center"  data-width="30px" >序号</th>
						<th data-field="createTime" data-formatter="MGrid.getTime"  >创建时间</th>
						<th data-field="hacName" data-sortable="true">活动名称</th>
						<th data-field="orderType" data-formatter="formatType">订单类型</th>
						<th data-field="nickName" >微信昵称</th>
						<!-- <th data-field="userName" >联系人</th> -->
						<th data-field="userPhone" >联系电话</th>
						<th data-field="orderCode" >消费码</th>
						<th data-field="prizeName" >奖品名称</th>
						<!-- <th data-field="prizeImg" >奖品图片</th> -->
						<th data-field="orderStatus" data-formatter="formatStatus">状态</th>
						<th data-align="center"  data-width="150px" data-field="orderId" data-formatter="buidOperate">操作</th> 
					</tr>
				</thead>
			</table>
	</div>
	</div>
</div>
</div>
<script type="text/javascript"
src="${path }/resource/js/systools/MJsBase.js"></script>
<script type="text/javascript">
	
	var myGrid;
	
		$(function(){
			var delPath="";
			<matrix:btn value="order:del">
			delPath="${path}/do/admin/bizOrder/del";
			</matrix:btn>
			 myGrid=MGrid.initGrid({
				 url:"${path}/do/admin/bizOrder/showList",
				 onLoadSuccess:function(data){
						console.log("onLoadSuccess:")
					},
				 delUrl:delPath
			 });
			 
		});
		function formatStatus(val, row, index){
			var str="";
			//1:保存 2：发布 3：下架 4：删除
			if(val=='1'){//text-primary
				return "<sapn  class='text-muted'>待消费</span><br>"+str
			}else if(val=='2'){
				return "<sapn class='text-success'>已消费</span><br>"+str
			}else if(val=='3'){
				return "<sapn class='text-danger'>已失效</sapn><br>"+str
			}
			return ""
		}
		function formatType(val, row, index){
			var str="";
		
			if(val=='1'){//text-primary
				return "<sapn class='text-danger'>分享</span><br>"
			}else if(val=='2'){
				return "<sapn class='text-success'>助力</span><br>"
			}
			return ""
		}
		
		
		function buidOperate(value, row, index){
			var html=[];
			<matrix:btn value="order:edit">	
					if(row.orderStatus=='1' ){
						html[1] = '<a onClick="consumer(\'' + value
						+ '\')"  title="消费" class="fa fa-check option"></a>'
					}
			</matrix:btn>
			/* <matrix:btn value="order:del">
			html[3] = '<a onClick="myGrid.delItem(\''
					+ value
					+ '\')" title="删除" class="fa fa-close option text-danger"></a>';
			</matrix:btn> */
			return html.join(""); 
		}
		
		<matrix:btn value="order:add">
		//打开添加界面
		function openAdd() {
			layer.full(layer.open({
				type : 2,
				title : "添加活动",
				maxmin : true,
				area : [ MUI.SIZE_L, '500px' ],
				content : [ '${path}/do/admin/bizOrder/editForm' ]
			}));
		}
		</matrix:btn>
		<matrix:btn value="order:edit">
		//打开编辑界面
		function openEdit(id) {
			layer.full(	layer.open({
				type : 2,
				title : "编辑活动",
				area : [ MUI.SIZE_L, '500px' ],
				maxmin : true,
				content : [ '${path}/do/admin/bizOrder/editForm?id=' + id ]
			}));
		}
		</matrix:btn>
		
		function formatStr(val){
			var s=val;
			if(val){
				if(val.length>10){
					  s=val.substring(0,10)+"...";
					  return "<abbr title='"+val+"'>"+s+"</abbr>";
				}
				
			}
			return val;
		}
		
	
		
		function consumer(val){
			 layer.confirm('是否确认消费？', {
				  btn: ['确认','取消'] //按钮
				}, function(){
					var index = layer.load(1, {
			        	  shade: [0.6,'#fff'] //0.1透明度的白色背景
			        	});
					$.AjaxProxy(
							{
								p : {orderId:val}

							}).invoke(
							"${path}/do/admin/bizOrder/consumer",
							function(loj) {
								layer.close(index);
								if(loj.getValue("status")=='200'){
									myGrid.serchData();
									layer.msg(loj.getValue("info"),{icon:1,time:2000})
								}else{
									layer.msg(loj.getValue("info"),{icon:2,time:2000})
								}
							})
				})
			
		}
	</script>
</body>
</html>
